package com.bbzn.device.client.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

/**
 * @Author wulongbo
 * @Date 2021/12/2 10:21
 * @Version 1.0
 */
public class ParamCheckUtils {

    public static boolean checkJson(List<String> list, String payLoad) {
        JSONObject jsonObject = JSONObject.parseObject(payLoad);
        boolean flag = true;
        if (list.isEmpty()) {
            return !flag;
        }
        for (int i = 0; i < list.size(); i++) {
            if (!jsonObject.containsKey(list.get(i))) {
                flag = false;
                break;
            }
            continue;
        }
        if (flag) {
            for (int i = 0; i < list.size(); i++) {
                if (!OptionalBean.ofNullable(jsonObject.get(list.get(i))).isPresent()) {
                    flag = false;
                    break;
                }
                continue;
            }
        }
        return flag;
    }
}
